﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ClassLibrary.Data;
using System.Data;
using ClassLibrary.Entity;

namespace ClassLibrary.DAO
{
    public class TblQuoteDAO
    {
        private DBService _db = null;
        public TblQuoteDAO(String ConnectionString)
        {
            _db = new DBService(ConnectionString);
        }

        public DataTable TblQuote_Ins(TblQuote quote)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("sp_TblQuote_In",
                    new string[] { "@FullName", "@EmailAddress", "@JobSiteAddress", "@Suburb", "@Postcode", "@State", 
                                    "@DateTime", "@PhoneNumber", "@Category", "@Describle", "@SelectQuestion", "@Comments", "@Note", "@Type", "@Time" },
                    new object[] { quote.FullName, quote.EmailAddress, quote.JobSiteAddress, quote.Suburb, quote.Postcode, quote.State,
                                    quote.DateTime, quote.PhoneNumber, quote.Category, quote.Describle, quote.SelectQuestion, quote.Comments, quote.Note, quote.Type, quote.Time}, CommandType.StoredProcedure);

            }
            catch (Exception ex)
            {
                throw ex;
            }

            return dt;
        }

        public DataTable GetQuote_ByType(string p_OrderDateFrom, string p_OrderDateTo, int Type)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("sp_TblQuote_Get",
                    new string[] { "@p_OrderDateFrom", "@p_OrderDateTo", "@Type" }, new object[] { p_OrderDateFrom, p_OrderDateTo, Type }, CommandType.StoredProcedure);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }

        public DataTable getQuote_ByID(int IDQuote)
        {
            DataTable dt = null;
            try
            {
                dt = _db.ExeSP_DataTable("select * from TblQuote where IDQuote = @IDQuote", new string[] { "@IDQuote" }, new object[] { IDQuote }, CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return dt;
        }
    }
}
